<?php
class MenuWidget extends HomeAction{
	//导航栏目
	public function render($data){

		$typeid=isset($data['t'])?$data['t']:null;	//输出指定的栏目
		$tpl=isset($data['tpl'])?$data['tpl']:'/Menu.html';	//模板文件名
		if(isset($data['li'])){$li=$data['li'];}

		$menu=M('Menu');
		
		if(isset($data['pid'])){
			$list=$menu->where(array('pid'=>$data['pid'],'reveal'=>1))->field('typeid,name,typeurl,url,contenturl,typeid')->order('num')->select();
			$list=PublicAction::getUrl($list,$li);
			$this->assign('list',$list);
		}

		if($typeid){
			$list=$menu->where(array('typeid'=>$typeid))->field('typeid,name,typeurl,contenturl')->select();
			$list=PublicAction::getUrl($list,$li);
			$this->assign('list',$list);
		}

		if(is_string($typeid)){
			$where['typeid']=array('in',"{$typeid}");
			$list=$menu->where($where)->order('num')->select();
			$list=PublicAction::getUrl($list,$li);
			$this->assign('list',$list);
		}

		$this->display(dirname(__FILE__).$tpl);


	}

}
